asm
  ld sp,$FFFF
  end asm

#include "./library/smsrnd.bas"
#include "./library/pacmandelay.bas"

dim eee as uinteger at $E010
dim seed as uinteger at $E012
dim delay as uinteger at $E014
dim ee2 as uinteger at $E016
dim ee3 as uinteger at $E018
dim ee4 as uinteger at $E01A
dim eex as uinteger at $E01C
dim eey as uinteger at $E01E


sub oneplustwopalette(tid1 as uinteger,tvl1 as uinteger):
  poke $C800+tid1,((tvl1 band $00E)*16 )  bor((tvl1 band $F00)/128) 
  poke $C900+tid1,((tvl1 band $001)*128)  bor((tvl1 band $0F0)/8)   
  'poke $C800+tid1,((tvl1 band $00E)*16 )                           bor((tvl1 band $F00)/128) bor((tvl1 band $800)/$800)
  'poke $C900+tid1,((tvl1 band $001)*128) bor ((tvl1 band $00C)*8 ) bor((tvl1 band $0F0)/8)   bor((tvl1 band $080)/$080)
  end sub

sub oneplustwoputchar(txp1 as uinteger,typ1 as uinteger,tch1 as ubyte,tat1 as ubyte)
  poke $D000+(typ1*128)+(txp1*2),tch1
  poke $D001+(typ1*128)+(txp1*2),tat1
  end sub

seed=54321



for eee=$C800 to $C87F '-pal1
  seed=smsrnd(seed)
  poke eee,seed
  next

for eee=$C900 to $C97F '-pal2
  seed=smsrnd(seed)
  poke eee,seed
  next


for ee2=0 to 31
  for ee3=0 to 63
    seed=smsrnd(seed)
    oneplustwoputchar(ee3,ee2,(seed band 63)+128,seed band 128)
    next:next

for ee2=0 to 15
  for ee3=0 to 15
    oneplustwoputchar(ee3+47,ee2+15,ee2*16+ee3,0)
    next:next

eex=8:eey=8
eee=0
do

oneplustwoputchar(1,1,48+(int(eee/100) mod 10),0)
oneplustwoputchar(2,1,48+(int(eee/10) mod 10),0)
oneplustwoputchar(3,1,48+(eee mod 10),0)

ee2=in(0) bxor 255
oneplustwoputchar(1,3,48+(int(ee2/100) mod 10),0)
oneplustwoputchar(2,3,48+(int(ee2/10) mod 10),0)
oneplustwoputchar(3,3,48+(ee2 mod 10),0)

ee2=in(1) bxor 255
oneplustwoputchar(1,4,48+(int(ee2/100) mod 10),0)
oneplustwoputchar(2,4,48+(int(ee2/10) mod 10),0)
oneplustwoputchar(3,4,48+(ee2 mod 10),0)

ee2=in(2) bxor 255
oneplustwoputchar(1,5,48+(int(ee2/100) mod 10),0)
oneplustwoputchar(2,5,48+(int(ee2/10) mod 10),0)
oneplustwoputchar(3,5,48+(ee2 mod 10),0)

eex=eex-((ee2 band 4)/4)+((ee2 band 8)/8)
eey=eey-((ee2 band 1)/1)+((ee2 band 2)/2)




ee2=in(3) bxor 255
oneplustwoputchar(1,6,48+(int(ee2/100) mod 10),0)
oneplustwoputchar(2,6,48+(int(ee2/10) mod 10),0)
oneplustwoputchar(3,6,48+(ee2 mod 10),0)

ee2=in(4) bxor 255
oneplustwoputchar(1,7,48+(int(ee2/100) mod 10),0)
oneplustwoputchar(2,7,48+(int(ee2/10) mod 10),0)
oneplustwoputchar(3,7,48+(ee2 mod 10),0)




oneplustwoputchar(eex,eey,eee,0)

eee=eee+1
loop


do:loop

do

'poke $C800,%11100000  '- bbbrrrrr
'poke $C900,%11111111  '- bbbggggg

oneplustwopalette(0,$F00)
oneplustwopalette(1,$0F0)
oneplustwopalette(2,$00F)
oneplustwopalette(3,$C84)

for eee=$D000 to $DFFF step 2 'fgram
  seed=smsrnd(seed)
  poke eee,seed
  pacmandelay(1000)
  next


for eee=$C800 to $C87F '-pal1
  seed=smsrnd(seed)
  poke eee,seed
  pacmandelay(1000)
  next

for eee=$C900 to $C97F '-pal2
  seed=smsrnd(seed)
  poke eee,seed
  pacmandelay(1000)
  next




loop



for eee=$C000 to $C7FF '?
  seed=smsrnd(seed)
  poke eee,seed
  pacmandelay(1000)
  next



for eee=$C880 to $C8FF '?
  seed=smsrnd(seed)
  poke eee,seed
  pacmandelay(1000)
  next


for eee=$C980 to $C9FF '?
  seed=smsrnd(seed)
  poke eee,seed
  pacmandelay(1000)
  next

for eee=$CA00 to $CFFF '?
  seed=smsrnd(seed)
  poke eee,seed
  pacmandelay(1000)
  next





do:loop

do
for eee=$C000 to $DFFF
  seed=smsrnd(seed)
  poke eee,seed
  pacmandelay(1000)
  next
loop

do:loop




'- AM_RANGE(0x0000, 0x7fff) AM_ROM AM_REGION("maincpu", 0x10000)
'- AM_RANGE(0x8000, 0xbfff) AM_ROMBANK("bank1")
'- AM_RANGE(0xc800, 0xc87f) AM_RAM_WRITE(palette1_w) AM_SHARE("paletteram")
'- AM_RANGE(0xc900, 0xc97f) AM_RAM_WRITE(palette2_w) AM_SHARE("paletteram2")
'- AM_RANGE(0xd000, 0xdfff) AM_RAM_WRITE(onetwo_fgram_w) AM_SHARE("fgram")
'- AM_RANGE(0xe000, 0xffff) AM_RAM


'
'sub putchar(txpos as uinteger,typos as uinteger,tch as uinteger, tadr as uinteger,txor as ubyte)
'  dim trt as uinteger at $A000
'  'for trt=0 to 7
'  '  poke $A200+(txpos band 31)+(trt*32)+((typos mod 28)*256),peek(tadr+(tch*8)+trt) bxor txor
'  '  next
'  'minivadersldir32b($A200+(txpos band 31)+(trt*32)+((typos mod 28)*256), tadr+(tch*8),8)
'  'minivadersfillramxor32b($A200+(txpos band 31)+(trt*32)+((typos mod 28)*256),txor,8)
'
'  minivadersldirxor32b($A200+(txpos band 31)+(trt*32)+((typos mod 28)*256), tadr+(tch*8),8,txor)
'  end sub
'
'sub writetext(txpos2 as uinteger,typos2 as uinteger,ttxt as uinteger, tleng as uinteger,tadr2 as uinteger, txor2 as uinteger)
'  dim trt2 as uinteger at $A002
'  for trt2=0 to tleng-1
'    putchar(txpos2+trt2,typos2,peek(ttxt+trt2),tadr2,txor2)
'    next
'  end sub
'
'for eey=0 to 27
'  for eex=0 to 31
'    seed=smsrnd(seed)
'    putchar(eex,eey,96+(seed mod 9),@charmap01-253,$FF)
'    next:next
'
'for eey=0 to 7
'  for eex=0 to 15
'    putchar(eex+15,eey+11,eex+(eey*16),@charmap01-253,$FF)
'    putchar(eex+15,eey+19,eex+(eey*16),@charmap01-253,$00)
'    next:next
'
'writetext(15,9,@text01,14,@charmap01-253,$FF)
'
'exps=16
'eee=0
'
'do
'  ejst=peek($E008) bxor 255
'  putchar(3,9,48+ (ejst mod 10)  ,@charmap01-253,$FF)
'  putchar(2,9,48+ ( int(ejst/10) mod 10)  ,@charmap01-253,$FF)
'  putchar(1,9,48+ ( int(ejst/100) mod 10)  ,@charmap01-253,$FF)
'  eee=eee+1
'  if (ejst band 1)<>0 then:exps=exps-1:end if
'  if (ejst band 2)<>0 then:exps=exps+1:end if
'  eqq=96+(eee mod 9)
'  if (ejst band 4)<>0 then:eqq=96+4:end if
'  putchar(exps,7,eqq,@charmap01-253,$FF)
'  pacmandelay(2000)
'  loop
'
'
'
'seed=0
'
'delay=100
'
''for eey2=0 to 27
''  for eex=0 to 31
''    for eey=0 to 7
''      for eee=1 to delay:next
''      seed=smsrnd(seed)
''      poke $A200+eex+(eey*32)+(eey2*256),seed
''      next:next:next
'
'
'do
'  seed=smsrnd(seed):eey2=seed mod 28
'  seed=smsrnd(seed):eex=seed band 31
'  for eey=0 to 7
'    poke $A200+eex+(eey*32)+(eey2*256),$00
'    next
'  seed=smsrnd(seed):eey2=seed mod 28
'  seed=smsrnd(seed):eex=seed band 31
'  for eey=0 to 7
'    poke $A200+eex+(eey*32)+(eey2*256),$FF
'    next
'  seed=smsrnd(seed):eey2=seed mod 28
'  seed=smsrnd(seed):eex=seed band 31
'  for eey=0 to 7
'    seed=smsrnd(seed)
'    poke $A200+eex+(eey*32)+(eey2*256),seed
'    next
'  loop
'
'
'delay=1000
'do
'  for eee=$A200 to $BDFF
'    seed=smsrnd(seed)
'    poke eee,seed
'    next
'  for eee=1 to delay:next
'  for eee=$A200 to $BDFF
'    poke eee,0
'    next
'  for eee=1 to delay:next
'  loop
'
'
'do
'  loop
'
'text01:
'asm
'  defb "HELLO WORLD!!!!!"
'  end asm
'
'
'
'
'
''-------------------------------------------------------------------------------
'
'
'
